package easier.app.x.recycler;

import androidx.annotation.NonNull;
import java.util.Objects;

/**
 * @param <E> 包装进数据类型
 */
public class DataViewHolder< E > extends BaseViewHolder {

    private final E mElement;

    public DataViewHolder( int layout, E e ) {

        super( layout );
        mElement = e;
    }

    public E getElement() {

        return mElement;
    }

    @Override
    public boolean itemEquals( @NonNull TypeViewHolder obj ) {

        if ( obj instanceof DataViewHolder ) {
            Object element = ((DataViewHolder< ? >) obj).getElement();
            return Objects.equals( getElement(), element );
        }
        return super.itemEquals( obj );
    }

    @Override
    public boolean contentEquals( @NonNull TypeViewHolder obj ) {

        return true;
    }
}
